package com.example.spinning.controller;

import com.example.spinning.bean.Log;
import com.example.spinning.bean.Organ;
import com.example.spinning.service.LogService;
import com.example.spinning.service.OrganService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 日志管理
 */
@RestController
@RequestMapping("/log")
public class LogController  {
    @Autowired
    LogService logService;

    //按条件查找
    @RequestMapping(path = "/getSpecificValue/",method = RequestMethod.GET)
    public Map<String,Object> getSpecificLogs(
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "count") Integer count,
            Log log
    ){
        int totalCount = logService.getLogCountByCondition(log);
        List<Organ> log_list = logService.getSpecificLogs(page,count,log);
        Map<String,Object> map = new HashMap<>();
        map.put("totalCount",totalCount);
        map.put("log",log_list);
        return map;
    }
}
